home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 July / DPPCPRO0705.ISO / Extras / NetSupport Manager / setup.exe / DELREGKEY.SCP < prev    next >
Encoding:
Text File  |  2004-10-06  |  3.4 KB  |  100 lines

  1. // Author :             Andy Earp(NetSupport Ltd) 
  2. // File name :          DelRegKey.scp
  3. // Date created :       17/08/00
  4. // Description : 
  5.  
  6. //         Please run the script titled CreateRegKey.scp to see this script work successfully. This script has been written
  7. //         as a example of how to delete Keys and there values and will delete the key and values create by the script
  8. //         CreateRegKey.scp. If you choose not to run CreateRegKey.scp first then the script will create a temporary key
  9. //         so that the script will complete error free.  Please not that deleting vital keys from your machine can be very 
  10. //         destructive to your machine.  
  11.  
  12. Print "*************************************************************"
  13. Print " "
  14. Print " This script will delete the registry key created"
  15. Print " by the sample script Createregkey.scp. If the key "
  16. Print " does not exist on your local machine then it will"
  17. Print " temporarily create the key to delete."
  18. Wait (8)
  19.  
  20. Dim Valuenames
  21.  
  22. //Open the registry key created by CreateRegKey.scp
  23.  
  24. Handle = RegOpenKey (HKEY_LOCAL_MACHINE, "SOFTWARE\NetSupportTestKey") 
  25.  
  26. //if the handle returned is invalid create a temporary key.  This is deleted later.
  27.  
  28. If !Handle then
  29.     Print " "
  30.     Print " ****************************************************************"
  31.     Print " * The registry key was not found has it been created! *"
  32.     Print " * A temporary key has been created for the script to   *"
  33.     Print " * complete error free                                                    *"
  34.     Print " ****************************************************************"
  35.     Handle = RegCreateKey (HKEY_LOCAL_MACHINE, "SOFTWARE\NetSupportTestKey") 
  36.     Wait(10)
  37. EndIf
  38.  
  39. //This function enumerates all of the values within a specified registry key  
  40. If !RegEnumValues (Handle, Valuenames) then
  41.  
  42.     ...
  43. Endif
  44.  
  45. Print " "
  46. Print " If values exist in the registry they will be "
  47. Print " displayed and deleted from the Key."
  48. Wait (3)
  49.  
  50. For Each Value in Valuenames
  51.     Print " "
  52.     Print " Value name: - ", Value, " has been deleted!"            //Prints the name for each value in the key.
  53.     RegDeleteValue (Handle, Value)                                       //Deletes all the values found in the key.
  54.     Wait(2)
  55. Next
  56.  
  57. // It is important to always close a key when you have finished using it, if you do not close the key then when the scripts 
  58. // finishes the key will be closed automatically.
  59.  
  60. RegCloseKey(handle)
  61.  
  62. //Opens the registry key.
  63. Handle = RegOpenKey (HKEY_LOCAL_MACHINE, "SOFTWARE\NetSupportTestKey")
  64.  
  65. //Delete the key that was either opened or created.
  66. If Handle then
  67.     Print " "
  68.     Print " *************************************************************"
  69.     Print " "
  70.     Print " The below registry key has been deleted : "
  71.     Wait (3)
  72.     Print " "
  73.     Print " HKEY_LOCAL_MACHINE\SOFTWARE\ "
  74.     Print " NetSupportTestKey "
  75.     Print " "
  76.     Print " *************************************************************"
  77.     Print " "
  78.     RegDeleteKey( Handle, "")
  79.     Wait (4)
  80. Else
  81.     Print " "
  82.     Print " Unable to create or open the registry key ! "
  83.     Print " ************************************************** "
  84.     Print " "
  85.     Wait (4)
  86. Endif
  87.  
  88. //Closes the Registry key.
  89. RegCloseKey(handle)
  90.  
  91. Print "To edit or view the contents of this"
  92. Print "script right mouse button click"
  93. Print "on the Script icon and select Edit" 
  94. Wait (5)
  95.  
  96. //Copyright ⌐ 2000
  97.  
  98.  
  99.  
  100.